-- @owner: @songjing20
-- @date: 2023-01-17
-- @testpoint: 事务中关闭自动提交，提交/回滚

--step1:创建表;expect:成功
drop table if exists t_autocommit_0011;
create table t_autocommit_0011(c_int int);

--step2:开启事务，表中插入数据，设置autocommit=0，回滚;expect:执行成功
begin;/
insert into t_autocommit_0011 values(123);
set autocommit = 0;
rollback;

--step3:查询autocommit，查询表数据;expect:on，无数据
show autocommit;
select * from t_autocommit_0011;

--step4:开启事务，表中插入数据，设置关闭自动提交，提交;expect:执行成功
begin;/
insert into t_autocommit_0011 values(123);
set autocommit = 0;
end;

--step5:查询autocommit，查询表数据;expect:off，123
show autocommit;
select * from t_autocommit_0011;

--step6:清理环境;expect:成功
drop table t_autocommit_0011 cascade;
set autocommit = 1;